//
//  RoseDetailViewController.m
//  ROSE
//
//  Created by 艾阳 on 2018/6/4.
//  Copyright © 2018年 HeNanZhongDunYunAn. All rights reserved.
//

#import "RoseDetailViewController.h"
#import "RoseModel.h"
#import "RoseDetailView.h"
#import "BuyRoseViewController.h"

@interface RoseDetailViewController ()
@property (nonatomic,strong)RoseDetailView *roseDetailView;
@end

@implementation RoseDetailViewController
- (instancetype)initWithRoseID:(NSString *)roseID{
    self = [super init];
    if (self) {
        self.roseID = roseID;
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    self.title = @"rose详情";
    self.roseDetailView = [[RoseDetailView alloc]initWithType:MarketRoseDetail];
    [self.view addSubview:self.roseDetailView];
    
    [self.roseDetailView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.mas_equalTo(0);
        make.top.mas_equalTo(0);
    }];
    [self.roseDetailView.buyButton addTarget:self action:@selector(buyRose) forControlEvents:UIControlEventTouchUpInside];
    [self getRoseDetail];
}


/**
 获取玫瑰详情
 */
- (void)getRoseDetail{
    [[LMJRequestManager sharedManager] POST:[NSString stringWithFormat:@"%@/rose/rosedetails",url_base] parameters:@{@"ROSEID":self.roseID} completion:^(LMJBaseResponse *response) {
        if (response.error==nil&&[response.responseObject[@"errorcode"] isEqualToString:@"000000"]) {
            RoseModel *roseModel = [[RoseModel alloc]init];
            [roseModel setValuesForKeysWithDictionary:response.responseObject[@"dataobj"]];
            [self.roseDetailView fillDataWithRoseModel:roseModel];
        }
    }];
}

#pragma mark - 购买玫瑰
- (void)buyRose{
    BuyRoseViewController *buyRoseVc = [[BuyRoseViewController alloc]init];
    [self.navigationController pushViewController:buyRoseVc animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
